package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.model.User;
import com.zr.service.CxunameServiceljc;
import com.zr.serviceImpl.CxunameServiceImplljc;

public class CxunameControllerljc extends HttpServlet{
	//查询用户名是否被注册控制器
	CxunameServiceljc cs = new CxunameServiceImplljc();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf8");
		resp.setCharacterEncoding("utf8");
		PrintWriter pw = resp.getWriter();
		String uname = req.getParameter("uname2");
		int count = cs.findUserByUname(uname);
		if(count>0){//判断相同用户名个数是否大于0
			pw.write("1");
		}else{
			pw.write("0");
		}
		pw.flush();
		pw.close();
	}
}
